package com.maxmind.controller;

import org.springframework.web.bind.annotation.ExceptionHandler;


import com.maxmind.common.BusinessException;
import com.maxmind.common.Response;
import com.maxmind.common.validate.ResCode;

import lombok.extern.slf4j.Slf4j;

/**
 * @date 2020/6/13 16:12
 */
@Slf4j
public abstract class BaseController {

    /**
     * BusinessException
     */
    @ExceptionHandler({ BusinessException.class })
    public Response BusinessException(BusinessException e) {
        return Response.builderFail(e.getCode(), e.getMessage());
    }

    /**
     * Exception
     * @param e
     * @return
     */
    @ExceptionHandler({ Exception.class })
    public Response exception(Exception e) {
        log.error(e.getMessage(), e);
        return Response.builderFail(ResCode.ORDER_ERROR_1003, ResCode.ORDER_ERROR_1003_DESC);
    }
}
